# -*- coding: utf-8 -*-
"""
Created on 15-12-16 上午9:49
@file: ks.py
@author: Liangrong Li
@contact: liliangrong0@126.com
"""

import urllib
import urllib2
import cookielib
import re
import webbrowser

url = "http://www.kumhosunny.com/ds_admin/login.aspx"
loginID = 1031
valid_code_url = "http://www.kumhosunny.com/Controller/ValidateCode.aspx"

webbrowser.open_new_tab(valid_code_url)

check_code = raw_input("input checkCode : ")

print check_code
headers = {
    'User-Agent':'Mozilla/5.0 (Windows NT 5.1; rv:35.0) Gecko/20100101 Firefox/35.0',
}
post = {
    'ASP.NET_SessionId':'x5w1cmbkut0xq1uw3e0kq055',
    'CheckCode':check_code,
    'Hm_lpvt_da55a5ad2b5a321acbc3ff07775da228':'1450228310',
    'Hm_lvt_da55a5ad2b5a321acbc3ff07775da228': '1450053317,1450140157,1450226992,1450228310',
    # 'LogID':'1028',
    # 'LoginForm':'28B39364B419B41D2A266A31DD27112459E9870DA1EEA9B1BB46CF1816B9D67856801B310766E24C62F11381345EC1739258AB4B78F768DAE65923598A59A2042C1D7539E5B1B6DF842B05268885B91B5F65A6D222AA67A0975FA4D873A2D30357FC1179',
    'ManagePassword':'mUNysMbZNwDeJaVm8x7ISw==',
    'ManageRealName':'%e8%b6%85%e7%ba%a7%e7%ae%a1%e7%90%86%e5%91%98',
    'ManageUserID':'1',
    'ManageUserName':'admin',
    'bdshare_firstime':'1449793729899',
    'iLanguage':'0',
}
postdata = urllib.urlencode(post)
req = urllib2.Request(url,data=postdata,headers=headers)
resp = urllib2.urlopen(req)
html = resp.read()

with open('ks_2.html','w+') as f:
    f.write(html)

